#ifndef __SEARCHENGINESERVER_HPP__
#define __SEARCHENGINESERVER_HPP__
#include "KeyRecommander.hpp"
#include "WebPageSearcher.hpp"
#include "TcpServer.hpp"
#include "ThreadPool.hpp"

class SearchEngineServer
{
public:
    SearchEngineServer(const string & ip, short port);
    //与TCP相关，设置好sock
    void start();
    //启动服务器
    
    void onConnection(const TcpConnectionPtr & conn);
    void onMessage(const TcpConnectionPtr & conn);
    void onClose(const TcpConnectionPtr & conn);
    //三个回调函数的绑定操作，将自定义的业务逻辑写入Reactor
    
    void doTaskThread(const TcpConnectionPtr & conn, const string & string);
    //工作线程的任务函数，转交给线程池，然后线程池会把他再转交给每个线程
    
private:
    TcpServer _tcpServer;
    ThreadPool _pool;
    KeyRecommander _KeyRecommander;
    WebPageSearcher _webSearcher;
    ProtocolParser _protocolParser;

private:
    TcpConnectionPtr _ConnCB;
    TcpConnectionPtr _MessCB;
    TcpConnectionPtr _ClosCB;
};


#endif
